package com.google.cart.controller;

import com.google.cart.entity.GoodsEntity;
import com.google.cart.feign.ProductFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
//@RequestMapping("cart")
public class CartController {

    @Autowired
    ProductFeignService feignService;

    @GetMapping("test")
    String t1(){
        return "cart-response";
    }

    @GetMapping("getCartInfo")
    List<GoodsEntity> getCartInfo(){
        List<GoodsEntity> cart = feignService.getCart();
        return cart;
    }

    @GetMapping("t2")
    String t2(Integer id){
//        int i = 1/0;
        String res = feignService.t2(id);

        return res;
    }

    @GetMapping("t3")
    String t3(Integer id){
        String test = feignService.test(id);
        return test;

    }

    @GetMapping("t4")
    String t4() throws InterruptedException {

        Thread.sleep(5000);
        return "test4";

    }

}
